/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.sipper.exec;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import combi.utils.Couple;

public class RemoveEmptyKSIPs {
	
	private static String tagHead = "(?:(.+)->(.+))";

	public static void main(String[] args) throws IOException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String previous = "";
		boolean isFinish = false;
		while(! isFinish)
		{
			Couple<String, String> c = getNextBloc(in, previous);
			//System.err.println(c);
			isFinish = c.getSecond() == null;
			if (!isFinish)
			{	
				if(c.getFirst().split("\n").length>1)
				{
					System.out.println(c.getFirst());
				}
				previous = c.getSecond();
			}
		}
		in.close();
	}


	/**
	 * 
	 * @param in the FileReader
	 * @param previous previous part of the String
	 * @return couple of Strings. The first one is the resulting bloc, the second one is the last readed line.
	 * @throws IOException 
	 */
	public static Couple<String, String> getNextBloc(BufferedReader in, String previous) throws IOException
	{
		//System.err.println("BEGIN");
		Pattern recoHead = Pattern.compile(tagHead);
		Matcher m;
		String ch;
		String bloc = "";
		boolean hasHead = false;
		//System.err.println(previous);
		m = recoHead.matcher(previous);
		if (m.find())
		{				
			//System.err.println("PREVIOUS\t " + previous);
			bloc += previous + "\n"; 
			hasHead = true;
		}
		while((ch = in.readLine())!=null && !ch.isEmpty())
		{
			m = recoHead.matcher(ch);
			if (m.find())
			{
				//System.err.println("HEAD\t " + ch);
				if (hasHead)
				{
					//System.err.println("END_1");
					return new Couple<String, String>(bloc, ch);
				}
				hasHead = true;
			}
			if (hasHead)
			{

				//System.err.println("\t " + ch);
				bloc += ch + "\n";
			}
			//			else
			//			{
			//				System.err.println("NOHEAD\t " + ch);
			//
			//			}
		}
		//System.err.println("END_2");
		return new Couple<String, String>(bloc, ch);
	}
}
